package com.cff.shorturl.task;

import java.util.Date;

import com.cff.shorturl.db.DbFactory;
import com.cff.shorturl.db.DbManager;
import com.cff.shorturl.util.DateUtil;

public class LogTask extends CallbackTask {
	String surl;
	Date date;
	boolean update = false;

	@Override
	public void doTask() throws Exception {
		logger.info("执行任务开始。");
		DbManager db = DbFactory.createDbManager();
		String insql = "insert into t_short_info(date,surl) values (?,?)";
		if (update) {
			insql = "update t_short_info set update_date = ? where surl = ?";
		}
		db.execute(insql, DateUtil.format(date, DateUtil.SimpleDatePattern), surl);
	}

	public String getSurl() {
		return surl;
	}

	public void setSurl(String surl) {
		this.surl = surl;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public boolean isUpdate() {
		return update;
	}

	public void setUpdate(boolean update) {
		this.update = update;
	}

}
